package com.ruoyi.jjm.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.jjm.mapper.SupplierOrderMapper;
import com.ruoyi.jjm.domain.SupplierOrder;
import com.ruoyi.jjm.service.ISupplierOrderService;
import com.ruoyi.common.core.text.Convert;

/**
 * 供应商订单Service业务层处理
 * 
 * @author tsr
 * @date 2020-07-15
 */
@Service
public class SupplierOrderServiceImpl implements ISupplierOrderService 
{
    @Autowired
    private SupplierOrderMapper supplierOrderMapper;

    /**
     * 查询供应商订单
     * 
     * @param id 供应商订单ID
     * @return 供应商订单
     */
    @Override
    public SupplierOrder selectSupplierOrderById(Long id)
    {
        return supplierOrderMapper.selectSupplierOrderById(id);
    }

    /**
     * 查询供应商订单列表
     * 
     * @param supplierOrder 供应商订单
     * @return 供应商订单
     */
    @Override
    public List<SupplierOrder> selectSupplierOrderList(SupplierOrder supplierOrder)
    {
        return supplierOrderMapper.selectSupplierOrderList(supplierOrder);
    }

    /**
     * 新增供应商订单
     * 
     * @param supplierOrder 供应商订单
     * @return 结果
     */
    @Override
    public int insertSupplierOrder(SupplierOrder supplierOrder)
    {
        supplierOrder.setCreateTime(DateUtils.getNowDate());
        return supplierOrderMapper.insertSupplierOrder(supplierOrder);
    }

    /**
     * 修改供应商订单
     * 
     * @param supplierOrder 供应商订单
     * @return 结果
     */
    @Override
    public int updateSupplierOrder(SupplierOrder supplierOrder)
    {
        supplierOrder.setUpdateTime(DateUtils.getNowDate());
        return supplierOrderMapper.updateSupplierOrder(supplierOrder);
    }

    /**
     * 删除供应商订单对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSupplierOrderByIds(String ids)
    {
        return supplierOrderMapper.deleteSupplierOrderByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除供应商订单信息
     * 
     * @param id 供应商订单ID
     * @return 结果
     */
    @Override
    public int deleteSupplierOrderById(Long id)
    {
        return supplierOrderMapper.deleteSupplierOrderById(id);
    }

    @Override
    public Double sumConfirmByVillage(Long villageId) {
        return supplierOrderMapper.sumConfirmByVillage(villageId);
    }

    @Override
    public Double sumTotalAmount(Long supplierId, Long areaId) {
        return supplierOrderMapper.sumTotalAmount(supplierId,areaId);
    }

    @Override
    public Double sumNotDeliverAmount(Long supplierId, Long areaId) {
        return supplierOrderMapper.sumNotDeliverAmount(supplierId,areaId);
    }
}
